﻿/**************************************************************************************************************
 * Class name:  ReflectionHelper.cs
 * Description: 反射助手
 * Author:      Ju2ender
 * Create:      2012-12-12 Wednesday 15:51:43
 * Update:      2012-12-12 Wednesday 15:51:43
 **************************************************************************************************************/

using System;
using System.Reflection;

namespace DearLee.Toolkit.Reflection {

  /// <summary>
  /// 反射助手
  /// </summary>
  public class ReflectionHelper {

    /// <summary>
    /// 为 Web 准备的 ToString 方法，用 br 分隔
    /// </summary>
    /// <param name="obj"></param>
    /// <returns></returns>
    public static string ToStringForWeb(object obj) {
      string msg = string.Empty;
      Type type = null;

      type = obj.GetType();

      foreach (PropertyInfo prop in type.GetProperties()) {
        msg += prop.Name + ": " + prop.GetValue(obj, null) + "<br />";
      }

      return msg;
    }
  }
}
